<template>
  <el-popconfirm
    :title="tipMsg"
    @on-confirm="click"
    @confirm="click"
    class="anvil-button anvil-button-text anvil-button-text-delete"
  >
    <template #reference>
      <el-button
        size="small"
        type="text"
        icon="promotion"
        v-hasPermi="perm"
        v-hasRole="role"
        v-hasRoleType="roleType"
        style="padding: 2px"
      >
        {{ text }}
      </el-button>
    </template>
  </el-popconfirm>
</template>

<script>
export default {
  name: 'TextReleaseButton',
  props: {
    text: {
      type: String,
      required: false,
      default: () => "发布",
    },
    title: {
      type: String,
      required: false,
      default: () => "",
    },
    subject: {
      type: String,
      required: false,
      default: () => "",
    },
    perm: {
      type: Array,
      required: false,
      default: () => [],
    },
    role: {
      type: Array,
      required: false,
      default: () => [],
    },
    roleType: {
      type: Array,
      required: false,
      default: () => [],
    }
  },
  computed: {
    tipMsg: function () {
      return this.title || ("是否确认" + this.text + (this.subject ? "[" + this.subject + "]" : "") + "?");
    }
  },
  methods: {
    click() {
      this.$emit('click')
    }
  }
}
</script>